<!DOCTYPE html>
<html lang="cn">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>PMS-business
		</title>
		<meta name="description" content="overview &amp; stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
	</head>
	<style>
        input{border:1px solid #D5D5D5;}
	</style>
	<body>
		<div class="row" id="customRedirectBox" style="margin-bottom: -24px;position: relative;">
        </div>
        <script type="text/javascript"> 
            var ins_argjson={};
            ins_argjson.scrname = 'guestlist'
            $(".page-content-area").ace_ajax("loadScripts", new Array(), function() {
                let urlHash=window.location.hash;
                
                if(urlHash.split("custom=").length>1){
                    let scrname = urlHash.split("custom=")[1].split("&")[0]
                    ins_argjson.scrname = scrname
                }

                var src = $.HSAPI_APPCUSTOMPATH+"custom_"+ins_argjson.scrname+'.html'

                var fs = require('fs');
                let path = require('path');
                let PUBLIC_PATH = path.resolve(__dirname, src);
                
                let data = ""
                var custom_type = "public"      //"public" 公司库   和 "owner" 自己文件    写死的重加载
                // try {
                //     data = fs.readFileSync(PUBLIC_PATH, 'utf8')
                //     custom_type = "owner"
                // } catch (error) {
                //     custom_type = "public"
                // }
                
                if(custom_type == "owner"){
                    $("#customRedirectBox").append(data);
                    var onlyInitComponent = 'yes'
                    initCustom(onlyInitComponent)
                }else{
                    var onlyInitComponent = 'no'
                    initCustom(onlyInitComponent)
                }
            })

            function initCustom(onlyInitComponent){
                $("#customRedirectBox").height($(window).height()-150)

                $.custom().then(({custom,C_DataSource,C_Where,C_Grid})=>{
                    ins_argjson.custom = custom;
                    ins_argjson.C_DataSource = C_DataSource;
                    ins_argjson.C_Where = C_Where;
                    ins_argjson.C_Grid = C_Grid;

                    let scrname = ins_argjson.scrname;
                    let params = {"jn":JSON.stringify({"arg":{"scrname":scrname}})};
                    ins_argjson.C_DataSource.ScreenBizData = ins_argjson.C_DataSource.getScreenBizDefault(params)
                    let ScreenData = ins_argjson.C_DataSource.ScreenBizData

                    var s_width = ScreenData.screen[0]['width']!=""?ScreenData.screen[0]['width']:$(window).width()
                    var s_height = ScreenData.screen[0]['height']!=""?ScreenData.screen[0]['height']:$(window).height()
                    $.HSAPI_SETMODALSIZE(parseInt(s_width),parseInt(s_height),true)
                    
                    var text = ScreenData.screen[0]['title']||'自定义页面'
                    $("title").text(text)

                    
                    var param = {}
                    param.boxId = "#customRedirectBox"  //自定义DIV
                    param.onlyInitComponent = onlyInitComponent //仅加载组件
                    custom.init(ScreenData,param,function(){
                        
                    })
                }).then(()=>{

                })
            }
        </script>
    </body>
</html>
